<?php

declare (strict_types=1);
namespace App\Model;

use Hyperf\DbConnection\Model\Model;
use Hyperf\Database\Model\Builder;

/**
 * 优惠券统计model
 *
 * @Author czm
 * @DateTime 2020-04-16
 */
class CouponStatistics extends Model
{
    use SelectTrait;
    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected $table = 'coupon_statistic';
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */

    protected $fillable = ['date','use_amount','use_num','phone_use_amount','phone_use_num','oil_use_amount','oil_use_num','not_use_amount','not_use_num','expire_amount','expire_num','update_time','add_time','is_del'];
    protected $guarded=['id'];
    protected $hidden = ['is_del'];
    /**
     * The attributes that should be cast to native types.
     *
     * @var array
     */
    protected $casts = [
        'update_time'=>'datetime:Y-m-d H:i:s',
        'add_time'=>'datetime:Y-m-d H:i:s',
    ];
    // protected $appends = ['status_mapping'];

    const CREATED_AT = 'add_time';
    const UPDATED_AT = 'update_time';
    // protected $dateFormat = 'U';

    protected function boot(): void
    {   
        $this->bootTraits();
        //model 软删除过滤 避免每次查询都添加is_del条件 去除条件添加withoutGlobalScope
        $this->addGlobalScope('is_del', function(Builder $builder) {
            $builder->where($this->table.'.is_del',1);
        });
        // var_dump($columns);
    }

    protected $dateFormat = 'U';



}